package com.book.entity;


import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;

import java.io.Serializable;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

/**
 * 
 * 
 * @author yang
 * @email yang@gmail.com
 * @date 2020-12-05 15:21:51
 */
@Data
@TableName("t_order")
public class OrderEntity implements Serializable {
	private static final long serialVersionUID = 1L;

	/**
	 * 订单id
	 */
	@TableId
	private Long id;
	/**
	 * 订单状态【0->待付款；1->待发货；2->已发货；3->已完成；4->已关闭；5->无效订单】
	 */
	private Integer orderStatus;
	/**
	 * 订单详细id
	 */
	private String orderItemId;
	/**
	 * 订单总额
	 */
	private BigDecimal totalAmount;
	/**
	 * 图书总数量
	 */
	private Integer totalCount;
	/**
	 * 用户id
	 */
	private Long userId;

	/**
	 * 订单编号
	 */
	private String orderId;




	@TableField(exist = false)
	private List<OrderItemEntity> orderItemEntities;


	/**
	 * 显示状态[0-不显示；1-显示]
	 */
	@TableLogic(value = "1",delval = "0")
	private Integer showStatus;

	/**
	 * '订单状态【0->待付款；1->待发货；2->已发货；3->已完成；4->已关闭；5->无效订单】
	 */
	private Integer status;

	/**
	 * 创建时间
	 */
	@TableField(fill = FieldFill.INSERT_UPDATE)
	private Date createtime;


	@TableField(exist = false)
	private String formatDate;


	public String getFormatDate(){
		if(getCreatetime() == null){
			return null;
		}
		SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
		return simpleDateFormat.format(getCreatetime());
	}


}
